package com.aoxiang.zbox.mapper;

import com.aoxiang.zbox.model.entity.Label;
import com.aoxiang.zbox.model.vo.SimpleLabelVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface LabelMapper extends BaseMapper<Label> {
    /**
     * 查询全部未删除标签
     *
     * @param
     * @return java.util.List<com.aoxiang.zbox.model.vo.SimpleLabelVO>
     * @author aoxiang
     * @create 2025/3/8
     **/
    @Select("select id,name,color from label where is_deleted = 0")
    List<SimpleLabelVO> getAllSimple();

    @Select("select id,name,color from label where is_deleted = 0 and show_sort is not null order by show_sort asc")
    List<SimpleLabelVO> getShownSimple();

    @Update("update label set show_sort = #{showSort} where id = #{id}")
    void updateShowSort(@Param("id") Long id, @Param("showSort") int showSort);

    @Update("update label set completed_sort = #{completedSort} where id = #{id}")
    void updateCompletedSort(@Param("id") Long id, @Param("completedSort") int completedSort);
}
